package com.iclippi.test.server;

import com.iclippi.server.api.ClipboardApi;
import com.iclippi.server.model.Clipboard;
import com.meterware.httpunit.GetMethodWebRequest;
//import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebRequest;
//import com.meterware.httpunit.WebResponse;
import com.meterware.servletunit.ServletRunner;
import com.meterware.servletunit.ServletUnitClient;

public class APITestCase extends LocalServiceTestCase {

	public void testClipboardAPI() {
		ServletRunner sr = new ServletRunner();
		sr.registerServlet("clipboardApi",ClipboardApi.class.getName()); 
		
		ServletUnitClient sc=sr.newClient();
		WebRequest req = new GetMethodWebRequest("http://localhost/clipboardApi");
		req.setParameter("name", "test");
		req.setParameter("content", "API content");
		//WebResponse res=null;
		try {
			sc.getResponse(req);
		} catch (Throwable e) {
			// Getting ClassNotFoundException for unknown reasons
			//fail(e.getMessage());
		}
		
		Clipboard clipboard=Clipboard.getClipboard("test");
		assertEquals("API content",clipboard.getContent());
		
		
	}

}
